﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Rename
{
    public partial class Main : Form
    {
        public Main()
        {
            InitializeComponent();
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            DirectoryInfo di = new DirectoryInfo(txtDirName.Text.Trim());
            if (!di.Exists) return;
            FileInfo[] fis = di.GetFiles();
            foreach (var item in fis)
            {
                string path = item.FullName.Replace(item.Name, "") + item.Name.Replace(txtDel.Text.Trim(), "");
                item.MoveTo(path);
            }
        }

        private void txtDirName_DoubleClick(object sender, EventArgs e)
        {
            FolderBrowserDialog fbd = new FolderBrowserDialog();
            fbd.ShowNewFolderButton = false;

            DialogResult result = fbd.ShowDialog();
            if (result == System.Windows.Forms.DialogResult.OK)
            {
                txtDirName.Text = fbd.SelectedPath;
            }
        }
    }
}
